package main

import (
	"github.com/gin-gonic/gin"
	"github.com/spf13/viper"
	"go-admin-api/routers"
	"go-admin-api/utills/generateDBModelUtill"
	"os"
)
// @title Swagger Example API12222
// @version 1.0
// @description This is a sample server Petstore server.
// @termsOfService http://swagger.io/terms/

// @contact.name API Support
// @contact.url http://www.swagger.io/support
// @contact.email support@swagger.io

// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html

// @host petstore.swagger.io
// @BasePath /v1
func main() {
	generateDBModelUtill.StartGoGenertateAllTables()
	////初始化配置文件
	//InitConfig()
	////初始化数据库上下文
	//db:=common.GetDB()
	//defer db.Close()
	////初始化gin框架
	//InitGin()
}
//初始化gin框架
func InitGin()  {
	gin.SetMode(gin.DebugMode)
	r:=gin.Default()
	r=routers.InitRouter(r)
	port := viper.GetString("server.port")
	if port == "" {
		port="8080"
	}
	panic(r.Run(":" + port))
}
//初始化配置文件
func InitConfig() {
	workDir, _ := os.Getwd()
	viper.SetConfigName("application")
	viper.SetConfigType("yml")
	viper.AddConfigPath(workDir + "/configs")
	err := viper.ReadInConfig()
	if err != nil {
		panic(err)
	}
}